Add sahagin javaScript shared logic