refactoring chart creation