small refactoring and added handler onWindowResize