refactored code for testing the template