CGI directory logic fixed