Moved repeated logic outside of conditional.