add build_dict code for top