Refactoring command lock

- Refactoring the interact process
- Clean code
- Add an interface for handled ttl