many changes, rework of code