Updated error checking again