refactored the flash messages