changing the scrap code to build a(i) and S