fix not encoded query
use separate variable for maxPages and use up round function