added canSwap(int,int) functions