Performance issue due to long running substitution variable