Use source variable when getting media attribute.

When retrieving the media attribute from a source, use the source variable on the line above rather than using sources[j] again.