passing state by pointer now