does this need to happen only here, or can we move this out of the "edit-only" route? The multiple if statements makes the code comment no longer tell the whole story.