Added automation and a few code lines