Adding code for directional control.