improved existing js snippets