updated error hadnling, fixed error messages