draft of js implementation