working version
relations implementation