properly handle resize