Maybe you should start by checking the return values of function calls