Encoded working almost correctly