Added extra null-checks