updated query on index method (posts controller)