output calculation corrected