updated update() to use the current speed instead of constant speed.