add pattern maching helper functions