Ah yes, just back and forth works :D by looping you were essentially doing the back and forth but a longer one, those gaps exists in case you get stuck in between the space, say both side gates closed, just so that you can get out and retry the level