changed input into queues and fixed bugs