Refactored d_control.js