Update metadata.js

made enclosing a bit more intelligent