Moved app logic into separate js file