better handling of resize