Error in Logic in Decreasing function, fixed