Create better structure and error fixing in several files.
merging the code, add create template function to call
Add comments to my code