Just looked at your function

& modified the way we calculate speed