Adjusted to work with permalinks