added states and event handling from tv