Added logic for searching posts