Update js requires and code refactor