Fixed error in message direction query