Rewrite expand-pattern