refactor bencoding