added null check for context