chart code refactoring!!! 2