minor details to the insertion
Correction of calculation of the states

Finally a decent calculation for achieving the right states