Dirty but working version with closed loop