added a nil value check