corrected getting metadata when looping