refactor managementState function