Fixed chart output. Now its sorted, and less code