Logic optimization for wfExpandUrl()