fixed bug 400877 and 40076