simplified and optimized