Adding checkFinal to close db connection