let count return 0 in error cases
make metadata action more robust