Fix for StateException problem
Fix for StateException problem