Fixed error when resizing