Small refactoring to move side effects closer together