Rewritten in FDR3 runnable .csp format