fix a bug with mem dependency detection