changed the resize alghorithm