min function added