small refactoring of the API