added maincontroller logic