minor refactor and prettifying of code in main controller