Refactor Api module