fix bug, optimizatoin