added saving messages to database