Make sure state is valid before accessing it
Signed-off-by: Poornima Gupte <poornima.gupte@in.ibm.com>