Moved the location of error checking.