added pollLast/poll based on mode
fixed merge