Refactor post logic