refactored api wrapper