refactor generate to support config file