Merge code and add comments