simplify error checking