refactored the state fetching