more refactoring for MLSS BGD example