Change priority function
Add counter for nodes in the stack
Change condition in the solver loop