rewrite of ksp scripts