Change the method to get the last key for array.