Refactored with function.

Added text input with function support.