made $pattern optional