Added check for zero pattern