encapsulated the api