Breaking apart the post function into multiple small functions