merge now uses index to allow comparison with function