refactored  MinMax Function for Activities