Algorithm seems to work now.  Still need to grab attribute of first element in arrays