Made the code more compact for demonstration