refactory custom post type