refactor for multi input