Code rewrite for clarity