Fixed stupid mistake while computing direction and magnitude