added code for the flyweight pattern