Small refactoring to reduce complexity