changes to controller logic and switch for state