Improve logic in do_post_logic()