refactor to support multiple inputs