Bug fix on resize