made some code optimisation for the driving system