added state handling