tidy and unify code