modified the state and added task update whenever a state change happends