rework logic to take into account the gray box resizing