split out messages into separate function
refactoring app file