Added check against the use of the same ref multiple times