functionality for GET and POST