fixed bug in queue implementation (caused a deadlock)