fix function calculateE()