if (isset($firstPoint->time) && isset($lastPoint->time) && $firstPoint->time instanceof \DateTime && $lastPoint->time instanceof \DateTime) {
            $this->stats->duration = $lastPoint->time->getTimestamp() - $firstPoint->time->getTimestamp();

            if ($this->stats->duration != 0) {
                $this->stats->averageSpeed = $this->stats->distance / $this->stats->duration;