Moving some processing data for directions into the setDirections function