fixed null check error in gathering sccript