Fixed completed check and reversed the logic to calculate