add moments calculations
better boundary checking for emax