add minpercent option and fix rounding problem