fix resize that goes beyond the boundary