script has been completely re-worked