Refactored out plotting