adding error handling in client