removed stolen stackoverflow and used merge instead