Placed repeated inbox and sent SQL operations into appropriate helper functions