Refactored the state output as per the discussion in the PR