Getting dependencies only if necessary