Refactored Nth func