Added extra null checks