why can't you call markMessagesRead for all id in one call ? you're already doing the "mark one message at a time" algorithm in markMessagesRead