Fix bug that picks wrong file to get metadata from