first try at minimum function