add encoding helper functions