refactoring post controller