final script including everything