Added functions for pattern matching