Can you post the whole code for reference? Everything seems to be right here.
And also format the code.