Implementation of tail