updated classic to be more close to the true classic method, and simplifed the margin and max_gap argunments