merging the code, add create template function to call
Add comments to my code