checkIfMobile() is now called only once