upperLimit function done for python