Moved computations to where they are used