add two function to encode