refactoring prepare data for template logic