Solving client closure issue