Consolidated error checking