Refactor the OR logic code