Moved b and hostname to be global variables