Added more checking to the client thread