fix a potential nil value error