implemented the code. Not tested
working code. need to improve with queue based logging..