fixing logic error with size of toswap