Sort of have it working now. The tiles are switching positions in mostly the right direction.