fixed bugs in window resize listener

by making clearStyles its own function