added nil check (settings undefined)