removed console.log and set null check