refactoring post class