alter logic in cgi to redirect properly