fixing calls to encode