added calculating speed to keep distance constant