Fixed bug where z would never be eligible for swapping