refactored the stage controller partially