build pattern with the correct source