add length attribute for to_dict