added anti periodic fit function