added error message and changed order