some state handling added