refactore flash messages device