Updated drive function with foldl