added check to writeDBRow