fixed buggy min script