Added basename null check