Performance adjustment to avoid calling a function multiple times when it
only needs to be called once.