Updated for Rotary Encoder