wrote the proper sort this time