refactor code in message js
refact code in message js