Attemping to fix state loop