refactoring
add flash messages