script has been totally rewriten