private function parseGoals(&$overview, $goalCollection)
    {
        $timespan = $overview->getTimespan() - $overview->getStartOffset();
        $goals = $overview->getGoals();
        if ($goals) {
            // delete existing entries
            foreach ($goals as $goal) {
                $this->em->remove($goal);
            }
            $this->em->flush();
        }

        foreach ($goalCollection as $goalEntry) {
            // create a new goal
            $goal = new AnalyticsGoal();
            $goal->setOverview($overview);
            $goal->setName($goalEntry['name']);
            $goal->setPosition($goalEntry['position']);

            $chartData = array();
            $totalVisits = 0;
            $goalVisits = 0;
            $i = 0;
            // Fill the chartdata array
            foreach ($goalEntry['visits'] as $timestamp => $visits) {
                $totalVisits += $visits;
                if ($timespan <= 7 && $timespan > 1) {
                    $goalVisits += $visits;
                    if ($i % 5 == 0) {
                        $chartData[] = array('timestamp' => $timestamp, 'conversions' => $goalVisits);
                        $goalVisits = 0;
                    }
                } else {
                    $chartData[] = array('timestamp' => $timestamp, 'conversions' => $visits);
                }
                $i += 1;
            }

            // set the data
            $goal->setVisits($totalVisits);
            $goal->setChartData(json_encode($chartData));
            $this->em->persist($goal);

            $this->output->writeln(
                "\t\t" . 'Fetched goal ' . $goal->getPosition() . ': "' . $goal->getName() . '" @ ' . $totalVisits
            );
        }
    }