changing stack to queue