finding upper bound