Corrected Bug in final value calculation