use slicing instead of a loop