eliminate some repeated computations