beginning of javascript restructure