A clean and efficient solution