Improved checkout ctrl. Refactored code.