refactor plot output method