impl to_dict
bugfix and follow new spec