refactoring and reporting func