Created a separate function to check if Relationexists