Improved clamp method

Now works properly if min > max.