First working version of auto join