Fix bug in api key code