TUP-2281:enhance the code a little.