refactor flash alert