generalized analyse_sg better for working with multiple intervals, now taking max instead of first