bug fix in getMagnitude method