implemented abstract factory pattern correctly