conversion from C to JS