Added null checks
Added null checks.