fix swap handling