arduino mega sonar and relay problem

I keep having the routine get stuck in a loop at end of ELSE IF statement.