refactored API to support chart API