reorganized main app logic into amd module