Accounting for empty array when getting keys