Code updated to fetch record id's using built in civi methods, namely: