I will do this for you. You can only mark answers, but i only commented by now.
For your solution: I thought you used the Z value directly and it was only positive (i should have noticed that it should be negative too). Using the length of it will make it positiv, because length is:
Sqrt(xx + yy + zz) and x and y were 0, so you got sqrt(zz) which will make it positive xD