Made resize safer