modified merge and flip methods