fix serialize object with to_dict method