final version of min