Rotation Assistance

hello
I have designed an Anti-aircraft canon. the canon is meant to move around (move around the Y-Axis) as well as moving up and down (around the Z-axis). I was able to make the canon move around the y-axis but the problem is when I try to move the canon up and down, the canon gets disconnected and moves to a random position on the screen.

can anybody tell me how can I make the canon move up and down the z-axis bearing in mind that the canon can be moved around the Y-axis so the z-axis needs to be updated to the new position of the Y-axis.