optimized cl code a bit by copying dimension vars to local variables