Improved join command code