Refactor flash messages