Attempting to fix Encoder Code