adds a function to pop the last element