added foreach loop to logPlanets function