refactor shapefactory