adding an error check