Compare diffrent measurements.

Try changing

if (microsec45 > microsec90)

to

if (microsec45 > microsec90) && (microsec45 > microsec135)

Might be a better way to do it though, but can't come up one myself sorry.