Fix bug for calculation