Avoid nil array access by checking key exists and returning nil if not found.