fix the bug when resizing