Refactor micropost code