using inject to compute final state and added compute final state method