generic way to get last in chain