updated build_coder function