Fixed issue in swap operation. close #1