implemented merge, still needs comments