working array comparison function