non-blocking feature added and tests also.