error checking functionality