Fix: encoding at wrong place