Modification in minimum algorithm