refactored from/join logic