fixed swap buffer bug