isolated the code for select the next available server

Change-Id: I271ab9dc169599b0152cf0a1a3010e1848f59a8a