Doing some extra error checking