refactored api functions