refactoring api to make it more abstract