Extracting common code to private method

Created a private method to build URL queries.

Change-Id: Iaa480443e34073fa39d13d2452cd13c267a2bdd5
Merge "Extracting common code to private method"