changed factory class to use singleton pattern