finished refactoring the post method