added state checks