Added options to add items at the beginning or end of the list