Turned application into a function