refactor get posts