implemented factory in the MainClass