main logic to check which page we are on