fixed the magnitude math problem