refactored core and api