Added encoder for movement detection