cook and merge codes