changed error checking thing