Fix invalid? method which determines when an association needs to be deleted
Refactoring