prepare for pattern optimization