New magnitude function fixes #3