Fixing Printing Function, error in outputing results