Issue #1237: JavaScript exception when adding new candidate genes
Better fix