merge the customized code from jn