Added few modifications on the implementation.