refactor of request/5 function