Grove Ultrasonic not working properly?

If I rewrite the echo part of the code in the void loop instead with a delay under it does it make it better? Or generally is there another way of writing the code for ultrasonic sensor. I am quite new to Arduino so I am still not sure about how it works.