Added checkForErrors method to simplify validation