moved setErrorMessages to main scope