added a functioning state manager