replaced queue implementation