update chart method and clean code