small reorganization
Main programm logic implemented