restructuring of encoding to make use of builder