added min(x,0)