added more output info and pass sum to be class global