refactor post controller and model