fix some control logic