Fixed a tail bug (duplicated code).