make unique array method more generalized