changed localhost to include the newly added variable $hostname.
Improved the detector for checking for randomization.