converted to JS