Move getServerName to a function