add error handler and comments