Refactored, added API example