Improve error messages. Little code cleanup
improve error message