Fixed queue dispatching

Fixed a bug in dispatching to queues