Fix queue
working algorithm, first glance