make join fuction more reliable