rewriting with_access to use group() instead of select(DISTINCT...)

We also need to overwrite count in that case so it does not return a hash