changed error messages and removed global error variable