finished speed controll code