Refactored main controller getting models code