modified to run in apache wsgi