In this code set minValue in second if is wrong and must replace with maxValue 
In this code set minValue in second if is wrong and must replace with maxValue
