added error types and comments