added reference check to permit script