Solution using Objects