Moved some control logic into the mode