refactor post method