Changed encoder reading function