Move exclusions and scandir within scanDir function