Refactoring initialize logic into controller