You might want to tidy up the brackets, either bracket mismatch or trailing bracket in last lines. Otherwise coding looks ok.