refactored fitting api