some script optimisations