move permalink checking logic to model