refactored cgi plugin