write log calculations on insert