fix bug, speed up