refactored api