Cleaning up logic: explicitly check response, rather than assuming below (which is harder to read)