two stage script fixed