completed, corrected and optimized