In this paper, we propose a new floor field Cellular Automaton (CA) model with considering the swapping behaviors of pedestrians. The neighboring pedestrians in opposite directions take swapping in a probability decided by the linear density of pedestrian flow. The swapping which happens simultaneously with the normal movement is introduced to eliminate the gridlock in low density region. Numerical results show that the fundamental diagram is in good agreement with the measured data. Then the model is applied to investigate the counterflow and four typical states such as free flow, lane, intermediate and congestion states are found. More attention is paid on the intermediate state which lane-formation and local congestions switch in an irregular manner. The swapping plays a vital role in reducing the gridlock. Furthermore, the influence of the corridor size and individual's eyesight on counterflow are discussed in detail. (C) 2017 Elsevier B.V. All rights reserved.