small refactoring
add metadata stats