fixing defensive swapping issue.