refactored join