actually i dont know what to say.
i just tested the program again and it was working successfully and never fail.
but i am still interested in securing my code. no way to hope that the bad condition never comeback