refactored m2m relations updating