add input provider
refactor the code