Fixed the exit condition for the for loops in TryPutPiece