trying to run 2 if statements in a loop without them intercepting

Hi, I’m trying to make a basic rotary encoder outputer where turning CW = 1 and CCW = 2 and click = CLICK but I can’t get them to run smoothly together. E.G. when turning encoder CW displays 1 or 2 or clicked and when clicking if statement is taken out runs CW = 1 and CCW = 2

#include <LiquidCrystal.h>
#define buttona 22
#define buttonb 23
#define clk 24

int busy = 0;
int a;
int b;
int clicked;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  pinMode(clk, INPUT);
  pinMode(buttona, INPUT);
  pinMode(buttonb, INPUT);
  lcd.begin(16, 2);
}

 void loop() { 
   a = digitalRead(buttona);
   clicked = digitalRead(clk);


   
   if (a != b){     
     if (digitalRead(buttonb) != a) { 
       lcd.home();
       lcd.print("2");
     } else {
       lcd.home();
       lcd.print("1");
     }
     if (clicked == LOW){
       lcd.home();
       lcd.print("CLICK");
   }   
   } 
   b = a;
 }

Why is the test for the button being clicked inside the test whether a != b ?
Are the turning of the encode and clicking of the button not independent ?