fixing calculation error