restructured input and output,output added result