Refactor Shape.ts