I haven't test your code, but this line :

if(!result <= 0) sys_exit("");

you're trying to test if result not <= 0 then exit game.