In your previous post you said

When I click slowly on newly added listitem, everything is working fine. If I do that faster, I get error on line 231.
So if the error occurs the code stops on that line and then you can check the value of those variables. This could go a long way to helping find the problem.