added try statement for plot flag