Moved error handler to helpers