fixing javascript bug and improving running chart