working on sort logic, does not work yet