Adjusted error checking