Fix bug in refreshing graphs