modified to add checking for server environment