Refactor for better API