Modified the getInstance Method to be more thread safe