adding in more logic to make plot look good