version 2 with error messages