refactory the strcuture and the initial script