code clean up. added the template to use