fixed syntax error

fixed syntax error and clean up code