fix nth bug