fixed some bugs for stacked fitting