Making a 3 axis robot arm look at something

I fixed it, I was told by someone that the middle axis is completely useless so I remade the arm part and swapped the top and bottom joints and it just works!