CoM script optimised slightly