minor: use respond_to? and index of array instead of first.last