more intelligent resize