modules for pattern analysis