works for 2000000. cleaned and commented