fixed #177; simplified the calculation via Walt