Fixed bug on window resize