Fixing bug in queue script