This function looks good, but why does it take `direction` as an argument instead of constructing the list itself? Is there a time when you would want to pre-populate it?