for fitting stacked and non stacked data