refactor command and add packet