Placed the iOS test outside the loop