Fixed a minor error that was causing only the last reference to really be looked at