fixed bug for state logging