added working chart function