patch $$ not being defined