@ixxxl,
This was the only line that seemed suspicious to me. So I commented it out and tested the code.