changed thread of the client to methods.and made some minor changes as well