Improved structure of megno calculation in code