refactor some files and add first for functional javascript