start rewrite all the crapola for n - period case