move depth build into build_relation