I already added something like this, which is more robust in https://github.com/KSHSK/WAVED/pull/130