bug fixes and new(not working yet) plotting file