fixed wrong check and display of errors