Added null check in rangy