checks if array key exists before the value gets returned and if not, returns the value of the first array key