Implemented merge functionality