refactor and code cleanup on input component