```ruby
if @project.id.to_s == params[:target_project_id]
  @project
elsif @project.forked_from_project && @project.forked_from_project.id.to_s == params[:target_project_id]
  @project.forked_from_project
else
   Project.forked_to(@project).find {|proj|proj.id.to_s == params[:target_project_id]}
end
 +    

```