Bug fix in showing input end Sequence
Refactoring code
Fix to handle timeouts better