base function and test on chrome and safari
refactoring.
Refactoring of the file structure and fixed bugs.