added states and command management