decomposition of similar code