fix api key variable + res end before final res end