menu on a display

I am trying to make a menu on a nokia 5110 display. the up and down works perfectly fine but when I press select the display tries to go between the page and the menu screen at the same time I don’t know why please help.

[code]
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

const int backLight = 9;
const int buttonUp = 12;
const int buttonSelect = 11;
const int buttonDown = 10;

int upState;
int selectState;
int downState;
int lastUpState;
int lastSelectState;
int lastDownState;
int item;
int contrast = 50;
int selection = 0;
boolean light = 0;

void setup(){
  display.begin();
  display.setContrast(contrast);
  display.display();
  delay(1);
  display.clearDisplay();

  pinMode(backLight, OUTPUT);
  pinMode(buttonUp, INPUT);
  pinMode(buttonSelect, INPUT);
  pinMode(buttonDown, INPUT);
}

void loop(){
  upState = digitalRead(buttonUp);
  selectState = digitalRead(buttonSelect);
  downState = digitalRead(buttonDown);

  checkIfbuttonUpIsPressed();
  checkIfbuttonSelectIsPressed();
  checkIfbuttonDownIsPressed();

  if(item > 3){item = 1;}
  if(item < 1){item = 3;}
  if(selection > 1){selection = 0;}

  switch(item){
    case 1:
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(BLACK);
    display.setCursor(0, 0);
    display.print("[item 1]");
    display.setCursor(0, 16);
    display.print("item 2");
    display.setCursor(0, 35);
    display.print("item 3");
    display.display();
    break;

    case 2:
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(BLACK);
    display.setCursor(0, 0);
    display.print("item 1");
    display.setCursor(0, 16);
    display.print("[item 2]");
    display.setCursor(0, 35);
    display.print("item 3");
    display.display();
    break;

    case 3:
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(BLACK);
    display.setCursor(0, 0);
    display.print("item 1");
    display.setCursor(0, 16);
    display.print("item 2");
    display.setCursor(0, 35);
    display.print("[item 3]");
    display.display();
    break;
  }

  if(item == 1){
    if(selection == 1){
      display.setTextSize(2);
      display.clearDisplay();
      display.setTextColor(BLACK);
      display.setCursor(0, 0);
      display.print("page 1");
      display.display();
    }
  }

   if(item == 2){
    if(selection == 1){
      display.setTextSize(2);
      display.clearDisplay();
      display.setTextColor(BLACK);
      display.setCursor(0, 0);
      display.print("page 2");
      display.display();
    }
  }

   if(item == 3){
    if(selection == 1){
      display.setTextSize(2);
      display.clearDisplay();
      display.setTextColor(BLACK);
      display.setCursor(0, 0);
      display.print("page 3");
      display.display();
    }
  }
  
}



void checkIfbuttonUpIsPressed(){
  if(upState != lastUpState){
    if(upState == HIGH){
      item++;
    }
  }
  lastUpState = upState;
}

void checkIfbuttonSelectIsPressed(){
  if(selectState != lastSelectState){
    if(selectState == HIGH){
      selection++;
    }
  }
  lastSelectState = selectState;
}

void checkIfbuttonDownIsPressed(){
  if(downState != lastDownState){
    if(downState == HIGH){
      item--;
    }
  }
  lastDownState = downState;
}

[/code]

When selection == 1, your code keeps flying though loop() first writing the item screen, then overwriting it with the page screen. You want to make them exclusive, something like this perhaps:

  if (selection > 1) {
    selection = 0;
  }

  if (0 == selection) {
    switch (item) {
      case 1:
        display.clearDisplay();
        // ...
        break;
    }
  } else { // selection == 1
    if (item == 1) { // or better still, a case statement like before
      display.setTextSize(2);
      // ...
    }
  }