changed several metafunctions into judgments, which fixed the errors on using undeclared variables