creating singleton and factory patterns