simplify and improve ntp calculation