Added terminal state function