fixed infinite loop bug + new db export