added flag related functions for handling sets of messages instead of using