extracted validRequest and endOfRequest methods