logical refactor