Brought in similarity to JS version