renamed mid to id for messages