refactor some code of the model for the charts