adds better logic for screen size changes