corrected optimal auction and refactored code