made the error messages slightly more specific. commented my code.