Fix query in message model