fixing my error checking