final version，more input