Implement LAST and NEXT