Why did you swap left and out_max? That's not making any sense to me.