reorganize profile_join code