clean up code using update-in function