getMessagesByType rewrite