add flash messages and extract class to files