refactoring - implementing api