Small refactoring to make code more linear