final boolean indexValid = (position >= -1 && position <= htmlRow.getCells().size());
if (indexValid) {
final HtmlElement newCell = ((HtmlPage) htmlRow.getPage()).createElement("td");
if (position == -1 || position == htmlRow.getCells().size()) {
htmlRow.appendChild(newCell);
}
else {
htmlRow.getCell(position).insertBefore(newCell);
}
return getScriptableFor(newCell);