create message js refactor