added check for final state
fixed some typos