Defined a method to set the speed