Refactored State and Task