rewrite minfree calculations