generalise table row insertion and deletion