fixed Upperbound code