This `if` structure can be consolidated into one function.