refactor flash error message