refactored code and added functionality to search for a string in the titles of the posts, pagination, used flash error messages and delete a post