abstracted code in js and add methods in message model
work on views