fix resize calculation bug