refactor code: get POST query