adding error checking to hw7