Rewrite code using update-in and assoc-in for clarity