refactor post logic