Adding error checking.