refactor post controller