adding check if rel exists
refactoring