updated control library, working control mode with on-switch recalculation