final version including validation of join table