pattern loader (still has bug)