function for adding element at end of list