A collective approach to cognition