Updated block to stop iteration if a y is detected