saving messages to the db