Fixes bug where function tries to get subset 'main' of ds
whenever factor is None.