Refactoring the ChartsHandler