flash messages refactor