some changes to improve performance and fix minor graphing bug