refactoring code
adding templates
test