refactored genrequest
str_replace doesn't allocate memory