fix the ordering of priorities and make it smarter

- now takes into account the completion of todos