add helper method for flash messages, and refactor layout view flash messages