min fuction added