Corrected to look for existing records before insert

Duplicate records are being inserted due to inccorect record_exists query. I updated it to what I think it should be and that corrected the issue.