Added catch code so that plotting doesn’t crash the program