removed encode function