encode working