Fixed typo in error checking