fix so that boolean is set to stop while loop in insert() method