refactored and started on resize behavior