The code is unfortunately not formatted correctly, so that I cannot debug it.
Could you wrap the code snippet into three backticks ```, so that we could have a look?
Also, try to compare your code to mine and check which part is different.