added some logic to the posts index view