group the same refs together in callback