Improved checkHome function in mousetracking