logic and sysout changed

main logic and one sysout changed