Refactoring

Fix undefined bug
Fix wrong id attribute handling
Fix wrong usage of template
Simplify and Refacto
Update README and index.html