Imlement DISCONNECT response
split code into multiple function