remove while loop to test as cgi script