made more readable and better error messages