improved error messages
added sql