Added encoding functions