Added best fit function and refactored method calling procedure