Api-agnostic refactor