refactor returning the data from peekQueue