Added extra null checks and