Made plot functional