Refactor: Move assignment outside of conditional