Refactor so that window width is checked on each call of checkHeight