refactor out shift and unshift