first attempt at encoding using the new API