fix a bug in automatic resizing