removed some extra params and added an extra null check.