Improved handleResponse to be generalized and renamed it handleEvent