refator control logic