added monotone algorithm