NoSuchElementException when adding item to empty list.

Exception caused by calling .last when list is Empty. Here's one of several ways to fix it.