Updated motor controller code