refactor communities relation on resources