fixed some bugs, added first and last list manipulation functions