split code at swap location passing tests