renaming aux into encode and removing top level code