Refactoring: move apiKey to API class
refactor spaghetti and handle interrupt right way