Created separate class with the so called heap_queue