reorganized main into app and controller files