TODO: state of global pointer does not get updated