check if pattern is present before checking it