significant modification for Issue#2 and Issue#23