Fix for error checking