Moved post request handler into seperate function