refactoring new post code