better error messages and removed debugs