improved API, refactored for encapsulation