encode properly