refactored flash messages, got them to work with ajax