error handling, add flash notices