resizing box but not at the right times