Moved permalinks into a separate function