trap error
refinement of error checking