TODO change api (add state change listener)