Moved app code to separate file