Added Factory pattern implementation.