Refactoring of javascript and settings on UI