changed implementation using singleton pattern.