better tofu implementation