add if else and seq_along()