Index min priority queue ; refactoring