some comments added to new logic