Rotation to the mouse cursor

Like in topic. I have entity sticked to camera (always in the centre of the screen) and I want to make rotate to the mouse cursor rotation. My code works, but it can’t get past the 0 angle line. Is there any way to fix it? All angles have values between 0 and PI*2.

        float deltaY = mouse.y - Display.getHeight()/2;
        float deltaX = mouse.x - Display.getWidth()/2;
        double desiredAngle = Math.atan2(deltaY, deltaX);
        desiredAngle+= (desiredAngle<0) ? Math.PI*2 : 0;
        desiredAngle-= (desiredAngle>Math.PI*2) ? Math.PI*2 : 0;
        
        if (desiredAngle>angle-Math.PI/64 && desiredAngle<angle+Math.PI/64) {}
        else if (desiredAngle>angle && desiredAngle<angle+Math.PI) {
            angle+= turnThrust/mass;
        }
        else if (desiredAngle<angle && desiredAngle>angle-Math.PI) {
            angle-= turnThrust/mass;
        }