Imrove JavaScript snippets