code made more dry